/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.softnight.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Franklin
 */
public class ConnectionFactory {
    
    private static String URL = "jdbc:postgresql://127.0.0.1:5432/brp";
    private static String DRIVER = "org.postgresql.Driver";
    private static String USUARIO = "postgres";
    private static String SENHA = "123456";
    private static Connection conn = null;

    public synchronized static Connection getConnection() throws SQLException {
        if (conn == null) {
            try {
                Class.forName(DRIVER);
                conn = DriverManager.getConnection(URL, USUARIO, SENHA);
            } catch (Exception e) {
                throw new SQLException(e.getMessage());
            }
        }
        return conn;
    }
}
